/**
 * Created by DukeCrushIt on 2015/8/27.
 */
class ActivityPanel extends eui.Component{
    public constructor(){
        super();
        this.skinName = "skins.scene.ActivityPanelSkin";
        //this.y = 75;
        this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAdded, this);
    }
    private onAdded(evt:egret.Event){
        this.validateProperties();
    }
    public updateMissions(){
        if(this.activeity_tab.selectedIndex == 1){
            this.listProvider.source = Model.curAchievements;
        }
    }

    public list:eui.List;
    private listProvider:eui.ArrayCollection;
    // private missionRender:eui.ClassFactory;
    private onSelectedTab(evt:egret.Event){
        SoundMgr.getInstance().playEffect(SoundMgr.BTN);
        // if( evt.oldIndex == 0){//todo 此处需要简化
        //     this._removeFromDisplayList(SignPanel.getInstance());
        //     this._addToDisplayList(this.list);
        //     if( evt.newIndex == 1){
        //         this.list.itemRenderer = this.missionRender;
        //         this.listProvider.source = Model.curAchievements;
        //         RedPointMgr.getInstance().update(RedPointMgr.ACHIEVE,false);
        //     }
        // }else  if( evt.newIndex == 0){
        //     this._removeFromDisplayList(this.list);
        //     this._addToDisplayList(SignPanel.getInstance());
        //     window["__signInfo"]();
        // }else{
        //     if( evt.newIndex == 1){
        //         this.list.itemRenderer = this.missionRender;
        //         this.listProvider.source = Model.curAchievements;
        //     }
        // }
    }

    public hint_achiev:eui.Image;
    public activeity_tab:eui.TabBar;
    public partAdded(name:string, instance:any){
        super.partAdded(name, instance);
        // if( name == "activeity_tab"){
        //     this.activeity_tab = instance;
        //     this.activeity_tab.itemRenderer = new eui.ClassFactory(ActivityTabButton);
        //     this.activeity_tab.dataProvider = new eui.ArrayCollection([0,1]);
        //     this.activeity_tab.addEventListener(egret.Event.CHANGE, this.onSelectedTab, this);
        // }else if(name == "hint_achiev"){
        //     this.hint_achiev = instance;
        //     RedPointMgr.getInstance().registerPoint(RedPointMgr.ACHIEVE,instance);
        // }
    }
    public childrenCreated(){
        super.childrenCreated();
        this.list = new eui.List();
        // this.list.skinName = "skins.simple.ListSkin";
        this.list.width = 440;
        this.list.height = 500;
        this.list.y = 45;
        this.list.x = 12;
        // this.missionRender = new eui.ClassFactory(MissionItemRender);
        this.listProvider = new eui.ArrayCollection();
        this.list.dataProvider = this.listProvider;
        // this._addToDisplayList(SignPanel.getInstance());
        // if(Model.signInfos== undefined || Model.signInfos.length == 0)
        //     window["__signInfo"]();
    }

    private static _instance:ActivityPanel;
    public static getInstance():ActivityPanel{
        if( ActivityPanel._instance == null)
            ActivityPanel._instance = new ActivityPanel();
        return ActivityPanel._instance;
    }
}